# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=ruby-rubytest-cli
pkgver=0.2.0
# https://github.com/rubyworks/rubytest-cli/issues/1
_commit=f57b301b69e0b074ac58d18ec553566b258b758b
pkgrel=2
pkgdesc='Rubytest CLI is a command-line interface for running tests for Rubytest-based test frameworks'
arch=(any)
url='https://github.com/rubyworks/rubytest-cli'
license=(BSD)
depends=(ruby-ansi ruby-rubytest)
options=(!emptydirs)
source=(https://github.com/rubyworks/rubytest-cli/archive/$_commit/$pkgname-$_commit.tar.gz)
sha256sums=('3bc1dff0a9677de6c9e85156820ab36719e484ab476af145abcef528697b902a')

build() {
  local _gemdir="$(gem env gemdir)"
  cd rubytest-cli-$_commit
  gem build .gemspec
  gem install \
    --local \
    --verbose \
    --ignore-dependencies \
    --no-user-install \
    --install-dir "tmp_install/$_gemdir" \
    --bindir "tmp_install/usr/bin" \
    rubytest-cli-$pkgver.gem
  find "tmp_install/$_gemdir/gems/" \
    -type f \
    \( \
        -iname "*.o" -o \
        -iname "*.c" -o \
        -iname "*.so" -o \
        -iname "*.time" -o \
        -iname "gem.build_complete" -o \
        -iname "Makefile" \
    \) \
    -delete
  rm -r tmp_install/$_gemdir/cache
  mkdir -p tmp_install/usr/share/man/man1
  mv tmp_install/$_gemdir/gems/rubytest-cli-$pkgver/man/*.1 tmp_install/usr/share/man/man1/
}

package() {
  cd rubytest-cli-$_commit
  cp -a tmp_install/* "$pkgdir"/
  install -Dm644 LICENSE.txt -t "$pkgdir"/usr/share/licenses/$pkgname/
}
